import 'package:flutter/material.dart';

/// 我的颜色
class ThemeDataUtils {
  static const MaterialColor white = MaterialColor(0xFFFFFFFF, <int, Color>{
    50: Color(0xFF666666),
    100: Color(0xFF777777),
    200: Color(0xFF888888),
    300: Color(0xFF999999),
    400: Color(0xFFAAAAAA),
    500: Color(0xFFBBBBBB),
    600: Color(0xFFCCCCCC),
    700: Color(0xFFDDDDDD),
    800: Color(0xFFEEEEEE),
    900: Color(0xFFFFFFFF),
  });

  /// 颜色数组
  static List<MaterialColor> colors = [
    Colors.indigo,
    Colors.red,
    Colors.blue,
    Colors.amber,
    Colors.cyan,
    Colors.deepPurple,
    Colors.green,
    Colors.pink,
    ThemeDataUtils.white,
    Colors.red,
  ];

  /// 主题样式数组
  static List<ThemeData> themes = colors
      .map((color) => ThemeData(
            primaryColor: color,
            primarySwatch: color,
          ))
      .toList();

  /// 获取颜色
  static MaterialColor getColorByIndex(int index) {
    if (index >= colors.length) index = 0;
    return colors.elementAt(index);
  }

  /// 获取主题样式
  static ThemeData getThemeByIndex(int index) {
    if (index >= themes.length) index = 0;
    return themes.elementAt(index);
  }
}
